import {
	GetOneDocter,
	GetAllDocter,
	CategoryData,
	GetFriendInfo
} from '@/api/docker.js'
const state = {
	docinfo: {},
	categoryId: {},
	DetailInfo: {},
	FriendInfo: []
}
const mutations = {
	//查询所有的首页医生
	GETONEDOCTER(state, info) {
		state.docinfo = info
	},
	//存放数据字典
	GETCATEGORY(state, info) {
		state.categoryId = info
	},
	//得到医生详细信息
	GETDOCTERDETAIL(state, info) {
		state.DetailInfo = info
	},
	//保存朋辈信息
	GEYALLFRIENDINFO(state, info) {
		state.FriendInfo = info
	}

}
const actions = {
	//查询单个的首页医生
	async GetoneDocter(context, id) {
		let res = await GetOneDocter(id)
		if (res.statusCode === 200) {
			context.commit("GETDOCTERDETAIL", res.data.result)
		}

	},
	// 	//首页查询所有的医生
	async getAllDocter(context, info) {
		const {
			current,
			keyword,
			size
		} = info
		let res = await GetAllDocter(current, keyword, size)
		if (res.statusCode === 200) {
			context.commit('GETONEDOCTER', res.data.result.list)
			return 'ok'
		}
	},
	//进行分类的数据字典
	async CategoryData(context) {
		let res = await CategoryData()
		context.commit('GETCATEGORY', res.data.result)
		return 'ok'
	},
	//得到朋辈互助
	async getAllFriendInfo(context) {
		let res = await GetFriendInfo()
		if (res.statusCode === 200) {
			context.commit('GEYALLFRIENDINFO', res.data.result)
			return 'ok'
		}

	}
}
const getters = {}
export default {
	state,
	mutations,
	actions,
	getters
}
